package com.pb.wkflow.api.controller.assembler.mapper;

import com.pb.wkflow.api.controller.request.ProcDefFieldRequest;
import com.pb.wkflow.api.controller.request.ProcDefineCreateRequest;
import com.pb.wkflow.api.entity.WfSysProcDefFieldEntity;
import com.pb.wkflow.core.utils.DateUtils;
import com.pb.wkflow.core.utils.SnowFlake;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.Date;

/**
 * 流程定义字段配置 DTOMapper
 * @author 苗益辉
 * @date 2023/4/17 16:15
 */
@Mapper(imports = {SnowFlake.class, DateUtils.class, Date.class})
public interface WfSysProcDefFieldDtoMapper {

    /**
     * 实例化
     */
    WfSysProcDefFieldDtoMapper INSTANCE = Mappers.getMapper(WfSysProcDefFieldDtoMapper.class);

    /**
     * 新增
     * @param request ProcDefFieldRequest
     */
    @Mappings({
            @Mapping(target = "id", expression = "java(SnowFlake.nextId())")
    })
    WfSysProcDefFieldEntity assemblerCreate(ProcDefFieldRequest request);

    /**
     * DTO 转 entity
     * @param request request
     * @return WfSysProcDefFieldEntity
     */
    WfSysProcDefFieldEntity assemblerDTOToEntity(ProcDefFieldRequest request);

    /**
     * 新增
     * @param request request
     * @return WfSysProcDefFieldEntity
     */
    @Mappings({
            @Mapping(target = "id", expression = "java(SnowFlake.nextId())"),
            @Mapping(target = "procDefKey", source = "key"),
            @Mapping(target = "procDefName", source = "name"),
            @Mapping(target = "classify", source = "classifyId")
    })
    WfSysProcDefFieldEntity assemblerCreate(ProcDefineCreateRequest request);
}
